<template>
  <div>
    <PublicHead
        :label="'指标名'"
        :add="add"
        :on-search="onSearch"
    ></PublicHead>
    <CollapseBody
        :table-data="this.showTableDada"
    ></CollapseBody>
    <AbstractionPopup></AbstractionPopup>
  </div>
</template>

<script>
import PublicHead from "@/components/share/PublicHead";
import CollapseBody from "@/pages/systemManage/abstractionList/CollapseBody";
import {mapActions, mapMutations, mapState} from "vuex";
import AbstractionPopup from "@/pages/systemManage/abstractionList/AbstractionPopup";

export default {
  name: "AbstractionList",
  components: {AbstractionPopup, CollapseBody, PublicHead},
  created() {
    let {objectId} = this.$router.currentRoute.params
    this.setState({name: 'currentKey', value: objectId})
    this.queryAllAbstraction()
  },
  computed: {
    ...mapState('abstractionList', ['tableData', 'showTableDada'])
  },
  methods: {
    ...mapMutations('abstractionList', ['setState']),
    ...mapActions('abstractionList', ['queryAllAbstraction']),
    add() {
      this.setState({name: 'popupVisible', value: true})
      this.setState({name: 'popupTitle', value: '新建'})
    },
    onSearch(val) {
      let list = []
      if (val) {
        for (let tableDatum of this.tableData) {
          if (tableDatum.label.indexOf(val) >= 0) {
            list.push(tableDatum)
          }
        }
      } else {
        list = this.tableData
      }
      this.setState({name: 'showTableDada', value: list})
    }
  }
}
</script>

<style scoped>

</style>
